# -*- coding: utf-8 -*-
"""
@Time ： 2023/11/16 0016 20:33
@Auth ： ysc
@File ：public_operation.py
@IDE ：PyCharm
"""
import platform
from Lib.log import log
from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromeService
from webdriver_manager.chrome import ChromeDriverManager


def getDriver():
    if platform.system().lower() == 'windows':
        log.info("当前的操作系统是windows")
        service = ChromeService(executable_path=ChromeDriverManager().install())
        driver = webdriver.Chrome(service=service)
        return driver
    elif platform.system().lower() == 'linux':
        log.info("当前的操作系统是linux")
        option = webdriver.ChromeOptions()
        option.add_argument('no-sandbox')
        driver = webdriver.Chrome(options=option)
        return driver
    else:
        log.error("EBS_Web_Auto_test框架仅支持在linux和windows两种操作系统上运行!")


if __name__ == '__main__':
    print("当前的操作系统是{}".format(platform.system().lower()))
